# file:: $Name$
# author::  $Author$
# version:: $Revision$
# date:: $Date$
#
# This source code copyright (C) 2006 by Ralph M. Churchill
# All rights reserved.
#
# Released under the terms of the GNU General Public License
# See LICENSE file for additional information.

class UsageException < RuntimeError
end

# Classes implementing Command will be 'loaded' at startup.
# Therefore, they must add themselves to the CommandDatabase
# in order to be usable.
#
# e.g. for the command Quit:
# class Quit < Command
# ...
# end
# CommandDatabase.instance.add(:Quit)
class Command
    attr_reader :executor, :name, :usage, :description
    # [+executor+] the entity executing the command
    # [+name+] the name used to invoked the command
    # [+usage+] command usage
    # [+description+] a brief description of the command
    def initialize(executor,name,usage,description)
        @executor = executor
        @name = name
        @usage = usage
        @description = description
    end
    def execute(params)
        raise NoMethodError("\"execute\" not implemented!")
    end
    def self.inherited(command)
        CommandDatabase.instance.add(command.to_s.to_sym)
    end
protected
    # a little helper method
    def inform(msg)
        GameEngine.instance.do_action(
            Action.new(:announce,self.executor,{:msg => msg}))
    end
end
